import { createRouter, createWebHistory } from 'vue-router'

import Login from '@/views/Login.vue'
import Layout from '@/views/Layout.vue'
import Manager from '@/views/Manage/Manager.vue'
import Merchants from '@/views/procurement/Merchants.vue'
import HandleOrder from '@/views/Manage/HandleOrder.vue'
import ManageMaterial from '@/views/Manage/ManageMaterial.vue'
import ManageMerchants from '@/views/Manage/ManageMerchants.vue'
import MyOrder from '@/views/procurement/MyOrder.vue'
import MyStore from '@/views/procurement/MyStore.vue'
import ProcurementTable from '@/views/procurement/ProcurementTable.vue'
import Info from '@/views/user/info.vue'
import Password from '@/views/user/password.vue'
import Avatar from '@/views/user/avatar.vue'

const routes = [
	{ path: '/', redirect: '/login' },
	{ path: '/login', name: 'Login', component: Login },
	{
		path: '/home',
		name: 'Layout',
		component: Layout,
		children: [
			{
				path: 'merchant',
				name: 'Merchant',
				component: Merchants,
				children: [
					{
						path: 'myorder',
						name: 'myorder',
						component: MyOrder,
					},
					{
						path: 'procurementtable',
						name: 'procurementtable',
						component: ProcurementTable,
					},
					{
						path: 'mystore',
						name: 'mystore',
						component: MyStore,
					},
					{
						path: 'info',
						name: 'merchantinfo',
						component: Info,
					},
					{
						path: 'password',
						name: 'merchantpassword',
						component: Password,
					},
					{
						path: 'avatar',
						name: 'merchantavatar',
						component: Avatar,
					},
				],
			},
			{
				path: 'manager',
				name: 'manager',
				component: Manager,
				children: [
					{
						path: 'handleOrder',
						name: 'handleOrder',
						component: HandleOrder,
					},
					{
						path: 'managematerial',
						name: 'managematerial',
						component: ManageMaterial,
					},
					{
						path: 'managemerchants',
						name: 'managemerchants',
						component: ManageMerchants,
					},
					{
						path: 'info',
						name: 'managerinfo',
						component: Info,
					},
					{
						path: 'password',
						name: 'managerpassword',
						component: Password,
					},
					{
						path: 'avatar',
						name: 'manageravatar',
						component: Avatar,
					},
				],
			},
		],
	},
]

const router = createRouter({ routes: routes, history: createWebHistory() })

export default router
